package com.swgk.core.view.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.swgk.core.R;
import com.swgk.core.interfaces.PopName;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * @author : younghow
 * @date : 2021/12/8 11:36
 * description:
 */
public class TwoLevelAdapter<T extends PopName> extends BaseRecycleAdapter<T> {
    boolean isShowSimple;
    private ImageView imageView;
    private boolean isShowGou;


    public void setShowSimple(boolean showSimple) {
        isShowSimple = showSimple;
    }

    public TwoLevelAdapter(Context context, List<T> datas, int tag) {
        super(context, tag, datas);

    }

    @Override
    public void convert(ItemViewHolder holder, T entity) {
        TextView tvName = holder.getItem().findViewById(R.id.tv_name);
        imageView = holder.getItem().findViewById(R.id.select_img);
        if (isShowGou) {
            imageView.setVisibility(View.VISIBLE);
            tvName.setBackground(context.getResources().getDrawable(R.drawable.only_select_province_item_bg));
        } else {
            tvName.setBackground(context.getResources().getDrawable(R.drawable.select_province_item_bg));
        }

        tvName.setText(entity.popName());
        tvName.getPaint().setFakeBoldText(holder.getItem().isSelected());
    }

    public void setImgStyle() {
        isShowGou = true;
    }
}
